/**
 * @projectName demo-master
 * @fileName UserController.java
 * @packageName org.example.nacos.data.controller
 * @author xaoyaoyao
 * @date 2021/3/24 14:11
 * @version V1.0
 * @copyright (c) 2021, xaoyaoyao@aliyun.com All Rights Reserved.
 */
package org.example.nacos.data.controller;

import org.example.nacos.data.model.User;
import org.example.nacos.data.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xaoyaoyao
 * @className UserController
 * @description
 * @date 2021/3/24 14:11
 */
@RestController
@RequestMapping("user")
public class UserController {

	private final UserService userService;

	@Autowired
	public UserController(UserService userService) {
		this.userService = userService;
	}

	/**
	 * http://localhost:8082/user?id=1
	 */
	@GetMapping
	@ResponseBody
	public User get(@RequestParam long id) {
		return userService.findById(id);
	}
}
